home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / scsiDiskBoot / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-16  |  2.8 KB  |  122 lines

  1. /* 
  2.  * main.c --
  3.  *
  4.  *    The main program for booting.
  5.  *
  6.  * Copyright 1986 Regents of the University of California
  7.  * All rights reserved.
  8.  */
  9.  
  10. #ifdef  notdef
  11. static char rcsid[] = "$Header: /sprite/src/boot/scsiDiskBoot.new/RCS/main.c,v 1.6 89/01/06 08:12:02 brent Exp Locker: mendel $ SPRITE (Berkeley)";
  12. #endif not lint
  13.  
  14.  
  15. #include "sprite.h"
  16. #include "machMon.h"
  17. #include "fs.h"
  18. #include "fsInt.h"
  19. #include "fsLocalDomain.h"
  20. #include "boot.h"
  21. #undef NO_PRINTF
  22. void Exit();
  23.  
  24. /*
  25.  *----------------------------------------------------------------------
  26.  *
  27.  * main --
  28.  *
  29.  *      This gets arguments from the PROM, calls other routines to open
  30.  *      and load the program to boot, and then transfers execution to that
  31.  *      new program.
  32.  *
  33.  * Results:
  34.  *    None.
  35.  *
  36.  * Side effects:
  37.  *    None.
  38.  *
  39.  *----------------------------------------------------------------------
  40.  */
  41.  
  42. main()
  43. {
  44.     ReturnStatus status;
  45.     register MachMonBootParam *paramPtr;/* Ref to boot params supplied
  46.                      * by the PROM montor */
  47.     register int index;            /* Loop index */
  48.     register int entry;            /* Entry point of boot program */
  49.     FsLocalFileIOHandle *handlePtr;    /* Handle for boot program file */
  50.     char *fileName = "vmunix";
  51.  
  52.     /*
  53.      * The Sun prom collects the boot command line arguments and
  54.      * puts makes them available throught the rom vector.
  55.      */
  56.     paramPtr = *romVectorPtr->bootParam;
  57. #ifdef notdef
  58.     for (index=0 ; index < 8; index ++) {
  59.     if (paramPtr->argPtr[index] != (char *)0) {
  60.         Mach_MonPrintf("Arg %d: %s\n", index, paramPtr->argPtr[index]);
  61.     } else {
  62.         break;
  63.     }
  64.     }
  65.     Mach_MonPrintf("Device %s\n", paramPtr->devName);
  66.     Mach_MonPrintf("File \"%s\"\n", paramPtr->fileName);
  67.  
  68.  
  69. #endif
  70. #ifndef SCSI3_BOOT
  71.     /*
  72.      * Set up for Block I/O to the boot device
  73.      */
  74.     Mach_MonPrintf("Sprite Boot %s(%d,%d,%d)%s\n", paramPtr->devName,
  75.              paramPtr->ctlrNum, paramPtr->unitNum,
  76.              paramPtr->partNum, paramPtr->fileName);
  77. #endif
  78.     /*
  79.      * Probe the boot device.
  80.      */
  81.     Dev_Config();
  82.     if (paramPtr->fileName[0]) {
  83.     fileName = paramPtr->fileName;
  84.     }
  85.  
  86.     status = FsAttachDisk(paramPtr->ctlrNum, paramPtr->unitNum, 
  87.               paramPtr->partNum);
  88. #ifndef SCSI3_BOOT
  89.     if (status != SUCCESS) {
  90.     Mach_MonPrintf("Can't attach disk, status <0x%x>\n",  status);
  91.     goto exit;
  92.     }
  93.     Mach_MonPrintf("Open File \"%s\"\n", fileName);
  94. #endif
  95.     /*
  96.      * Open the file to bootstrap.
  97.      */
  98.     status = Fs_Open(fileName, FS_READ, 0, &handlePtr);
  99.     if (status != SUCCESS) {
  100.     Mach_MonPrintf("Can't open \"%s\", <%x>\n", fileName, status);
  101.     goto exit;
  102.     }
  103.     entry = FileLoad(handlePtr);
  104.     if (entry != -1) {
  105.     Boot_Transfer(entry);
  106.     }
  107. exit:
  108.     return;
  109. }
  110.  
  111. /*
  112.  * Exit is called by start.s
  113.  */
  114. void
  115. Exit()
  116. {
  117.     /*
  118.      * Return to start.s and then the PROM monitor.
  119.      */
  120.     return;
  121. }
  122.